pp108 : Operators and Constants in Function Library

Operators and Constants in Function Library

This topic describes the various operators available in the function library.

The Function Library in the rule creator provides a set of functions and operators that can be used for framing simple as well as complex rules. The following sections describe the operators and constants that are provided by the function library.

Arithmetic Operators


Arithmetic operators allow you to define mathematical operations in rule expressions.

The following table describes the arithmetic operators you can select from the function library area while creating a rule.

Table 1. Arithmetic Operators

Operator Description Syntax
+ Adds e1 and e2 e1
+ e2
Subtracts e2 from e1 e1
- e2
Multiplies e1 and e2 e1
* e2
div Divides e1 and e2 (If e2 is 0, then the expression evaluates to 0.) e1
div e2
mod Gives the modulus(division remainder) of e1 and e2 e1
mod e2


Boolean Operators


Boolean operators evaluate expressions to true or false. The resulttruetakes the integer value 1 whilefalsetakes the value 0.

Table 2. Boolean Operators

Operator Description Syntax
and Logical and operator e1
and e2
or Logical or operator e1
or e2
= Equality operator e1
= e2
!= Inequality operator e1 != e2
< Less than operator e1
< e2
<= Less than or equal to operator e1
<= e2
> Greater than operator e1
> e2
>= Greater than or equal to operator e1
>= e2


Boolean Functions


The rule engine provides a set of boolean functions that can be used directly in a rule.

Table 3. Boolean Functions

Constant Description Value
true() function call for returning true 1
false() function call for returning false 0


Operator Precedence and Associativity


Operator precedence describes the order in which the rule engine reads expressions. Operators are arranged in descending order of precedence, that is, from the highest to the lowest. More than one operator appearing in a single row has the same precedence.

The following table lists the operators in the order in which the rule engine reads them. The associativity column specifies the direction in which each operator is read.

Table 4. Operator Precedence and Associativity

Operator Description Associativity
in Logical in operator Left to right
+ - Unary plus/minus operators Right to left
^ Power operator Left to right
  • div Mod
Multiplication, division, modulus operators Left to right
+ - Addition/subtraction operators Left to right
< <= Relational less than/less than or equal to operators No Associativity
> >= Relational greater than/greater than or equal to operators
= != Relational is equal to/is not equal to operators
and Logical and operator Left to right
or Logical or operator Left to right